{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7b875d89-dce0-4add-9e5c-fc242f98002e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([ 0.0000e+00,  0.0000e+00,  0.0000e+00,  ..., -6.1035e-05,\n",
      "        -1.2207e-04, -9.1553e-05])\n"
     ]
    }
   ],
   "source": [
    "import torchaudio.functional as F\n",
    "import torchaudio.transforms as T\n",
    "import torchaudio\n",
    "\n",
    "file = \"1031.wav\"\n",
    "\n",
    "print(torchaudio.load(file)[0][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1a569458-4cfe-4c50-b506-1ac5cc3c0e43",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(tensor([[ 0.0000e+00,  0.0000e+00,  0.0000e+00,  ..., -6.1035e-05,\n",
       "          -1.2207e-04, -9.1553e-05],\n",
       "         [ 0.0000e+00,  0.0000e+00,  0.0000e+00,  ..., -6.1035e-05,\n",
       "          -1.2207e-04, -9.1553e-05]]),\n",
       " 48000)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(torchaudio.load(file))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "d5c03a10-c8fe-4bf3-801e-42e79651a290",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "waveform = torchaudio.load(file)[0][0]\n",
    "resampler = T.Resample(48000, 8000, dtype=waveform.dtype)\n",
    "resampled_waveform = resampler(waveform).unsqueeze(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a088aff1-2fae-464d-987d-cad685cb80d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "torchaudio.save(\"10318k.wav\",resampled_waveform,8000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1,2,3]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
